package com.jyw.system.service.impl;

import com.jyw.common.constant.CacheConstants;
import com.jyw.common.core.redis.RedisCache;
import com.jyw.common.utils.SecurityUtils;
import com.jyw.system.service.ISysSeatService;
import org.apache.ibatis.cache.CacheKey;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SysSeatServiceImpl implements ISysSeatService {

    @Resource
    private RedisCache redisCache;

    @Override
    public boolean isSeatNow() {
        if(redisCache.hasKey(CacheConstants.SEAT_NOW)){
            Map<String, Object> cacheMap = redisCache.getCacheMap(CacheConstants.SEAT_NOW);
            return cacheMap.values().contains(SecurityUtils.getUserId());
        }
        return false;
    }


}
